const { defineConfig } = require('@vue/cli-service')
const path = require('path')  // 添加这行引入path模块

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')  // 现在path已正确定义
      }
    }
  },
   chainWebpack: config => {
    // 静态资源处理规则
    config.module
      .rule('images')
      .test(/\.(png|jpe?g|gif|webp|avif)(\?.*)?$/)
      .type('asset')
      .parser({
        dataUrlCondition: {
          maxSize: 4 * 1024 // 4KB 以下转 base64
        }
      })
      .set('generator', {
        filename: 'img/[name].[hash:8][ext]' // 输出路径+哈希文件名
      })
  }
  // 关键配置结束
})
